/**
 * Created by dqw on 2015/12/30.
 */

//列表开始
var dtGridColumns = [
    {
        id: 'delFlag',
        type: 'int',
        hideQuery:true,
        'export':false,
        hideQueryType:'eq',
        hideQueryValue:1,
        hide:true
    },
    {
        id: 'userId',
        type: 'number',
        hideQuery:true,
        'export':false,
        hide:true
    },
    {
        id: 'id',
        title: 'ID',
        type: 'number',
        columnClass: 'text-center width-100',
        fastSort: false
    },
    {
        id: 'u.userName',
        title: '用户名',
        type: 'string',
        headerClass: 'text-center',
        columnClass: 'text-center',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'lk'
    },
    {
        id: 'u.mobilePhone',
        title: '手机号码',
        type: 'string',
        headerClass: 'text-center',
        columnClass: 'text-center',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'lk'
    },
    {
        id: 'realnameStatus',
        title: '实名认证状态',
        type: 'string',
        headerClass: 'text-center',
        columnClass: 'text-center',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'eq',
        codeTable:{
            1:$lang.userIdentifyStatus.T1,
            2:$lang.userIdentifyStatus.T2,
            3:$lang.userIdentifyStatus.T3,
            4:$lang.userIdentifyStatus.T4

        }
    },
    {
        id: 'realnameVerifyTime',
        title: '实名认证审核时间',
        type: 'date',
        format:'yyyy-MM-dd',
        headerClass: 'text-center',
        columnClass: 'text-center',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'range'
    },
    {
        id: 'realnameVerifyRemark',
        title: '实名认证备注信息',
        type: 'string',
        headerClass: 'text-center',
        columnClass: 'text-center',
        fastSort: false,
    },
    {
        id: 'mobilePhoneStatus',
        title: '手机认证状态',
        type: 'string',
        headerClass: 'text-center',
        columnClass: 'text-center',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'eq',
        codeTable:{
            1:$lang.userIdentifyStatus.T1,
            2:$lang.userIdentifyStatus.T2,
            3:$lang.userIdentifyStatus.T3,
            4:$lang.userIdentifyStatus.T4

        }
    },
    {
        id: 'emailStatus',
        title: '邮箱认证状态',
        type: 'string',
        headerClass: 'text-center',
        columnClass: 'text-center',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'eq',
        codeTable:{
            1:$lang.userIdentifyStatus.T1,
            2:$lang.userIdentifyStatus.T2,
            3:$lang.userIdentifyStatus.T3,
            4:$lang.userIdentifyStatus.T4

        }
    },
    // {
    //     id: 'vipStatus',
    //     title: 'VIP认证状态',
    //     type: 'string',
    //     headerClass: 'text-center',
    //     columnClass: 'text-center',
    //     fastSort: false,
    //     fastQuery: true,
    //     fastQueryType: 'eq',
    //     codeTable:{
    //         1:$lang.userIdentifyStatus.T1,
    //         2:$lang.userIdentifyStatus.T2,
    //         3:$lang.userIdentifyStatus.T3,
    //         4:$lang.userIdentifyStatus.T4
    //
    //     }
    // },
    // {
    //     id: 'vipVerifyTime',
    //     title: 'VIP审核时间',
    //     type: 'date',
    //     format:'yyyy-MM-dd',
    //     headerClass: 'text-center',
    //     columnClass: 'text-center',
    //     fastSort: false,
    //     fastQuery: true,
    //     fastQueryType: 'range'
    // },
    // {
    //     id: 'vipEndtime',
    //     title: 'VIP到期时间',
    //     type: 'date',
    //     format:'yyyy-MM-dd',
    //     headerClass: 'text-center',
    //     columnClass: 'text-center',
    //     fastSort: false,
    //     fastQuery: true,
    //     fastQueryType: 'range'
    // },
];

var dtGridOption = {
    lang: 'zh-cn',
    ajaxLoad: true,
    loadURL: ncGlobal.adminRoot + 'userIdentify/list.json',
    exportFileName: '用户认证列表',
    columns: dtGridColumns,
    gridContainer: 'dtGridContainer',
    toolbarContainer: 'dtGridToolBarContainer',
    pageSize: 10,
    pageSizeLimit: [10, 20, 50],
    ncColumnsType: {int:["id","realnameStatus","mobilePhoneStatus","vipStatus","emailStatus","userId"],Timestamp:["realnameVerifyTime","vipVerifyTime","vipEndtime"]}
};

var grid = $.fn.DtGrid.init(dtGridOption);
grid.fastQueryParameters = new Object();
grid.fastQueryParameters['eq_delFlag'] = 1;

//排序
grid.sortParameter.columnId = 'id';
grid.sortParameter.sortType = 1;
//列表结束

//操作处理开始
var OperateHandle = function () {

    function _bindEvent() {

        //模糊搜索
        $('#customSearch').click(function () {
            grid.fastQueryParameters = new Object();
            grid.fastQueryParameters['eq_delFlag'] = 1;
            grid.fastQueryParameters['lk_real_name'] = $('#keyword').val();
            grid.pager.startRecord = 0;
            grid.pager.nowPage = 1;
            grid.pager.recordCount = -1;
            grid.pager.pageCount = -1;
            grid.refresh(true);
        });
    }


    //外部可调用
    return {
        bindEvent: _bindEvent
    }
}();
//操作处理结束

$(function () {
    //加载列表
    grid.load();
    //页面绑定事件
    OperateHandle.bindEvent();
});